<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>系统设置</title>

    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>

<body style="padding: 10px;">
    <div class="header">
        <div>
            <span class="layui-breadcrumb">
                <a>系统设置</a>
                <a>网站设置</a>
            </span>
        </div>
    </div>

    <div class="layui-panel" style="margin-top: 20px;padding: 5px;">
        <form class="layui-form layui-form-pane">
            <div class="layui-form-item">
                <label class="layui-form-label">网站名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="title" required lay-verify="required" placeholder="请输入网站名称"
                        autocomplete="off" class="layui-input" value="{$siteInfo.values.title}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">关键词</label>
                <div class="layui-input-block">
                    <input type="text" name="keywords" placeholder="请输入关键词" autocomplete="off" class="layui-input"
                        value="{$siteInfo.values.keywords}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">网站描述</label>
                <div class="layui-input-block">
                    <input type="text" name="desc" placeholder="请输入网站描述" autocomplete="off" class="layui-input"
                        value="{$siteInfo.values.desc}">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="formSubmit">提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>

    <script src="/static/layui/layui.js"></script>
    <script>
        layui.use(['layer', 'form'], function () {
            var layer = layui.layer;
            var $ = layui.jquery;
            var form = layui.form;

            //监听提交
            form.on('submit(formSubmit)', function (data) {
                var data = {
                    names: 'site_setting',
                    values: {
                        title: data.field.title,
                        keywords: data.field.keywords,
                        desc: data.field.desc,
                    }
                }

                $.post('/admin/setting/save', data, function (res) {
                    if (res.code == '200') {
                        layer.msg('操作成功', {
                            icon: 6,
                            time: 500
                        }, function () {
                            window.location.reload();
                        });
                    } else {
                        layer.msg(res.msg, {
                            icon: 5,
                            time: 1000
                        });
                    }
                }, 'json');

                return false;
            });
        });

    </script>
</body>

</html>